package com.xiaozhen.quartz.service;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaozhen.quartz.config.JobAndTrigger;

/**
 * @author zhenweisheng
 * @date 2020/9/30 9:05
 * @description:
 */
public interface JobService {

    /**
     * 添加简单任务（按cron表达式）
     *
     * @param jobClassName
     * @param jobGroupName
     * @param cronExpression
     * @param jobName
     * @throws Exception
     */
    void addJob(String jobClassName, String jobGroupName,
                String cronExpression, String jobName) throws Exception;

    /**
     * 添加任务（按开始时间，结束时间和间隔时间）
     *
     * @param jobClassName
     * @param jobGroupName
     * @param jobName
     * @param startTime
     * @param endTime
     * @param inteval
     * @throws Exception
     */
    void addDailyTimeIntervalJob(String jobClassName,
                                 String jobGroupName, String jobName, String startTime,
                                 String endTime, Integer inteval) throws Exception;

    /**
     * 暂停任务
     *
     * @param jobName
     * @param jobGroupName
     * @throws Exception
     */
    void jobPause(String jobName, String jobGroupName) throws Exception;

    /**
     * 恢复任务
     *
     * @param jobName
     * @param jobGroupName
     * @throws Exception
     */
    void jobResume(String jobName, String jobGroupName) throws Exception;

    /**
     * 修改任务
     *
     * @param jobName
     * @param jobGroupName
     * @param cronExpression
     * @throws Exception
     */
    void jobReschedule(String jobName, String jobGroupName,
                       String cronExpression) throws Exception;

    /**
     * 删除任务
     *
     * @param jobName
     * @param jobGroupName
     * @throws Exception
     */
    void jobDelete(String jobName, String jobGroupName) throws Exception;

    /**
     * 删除所有任务
     *
     * @throws Exception
     */
    void jobDeleteAll() throws Exception;

    /**
     * 查询任务
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    Page<JobAndTrigger> queryJob(Integer pageNum, Integer pageSize);

}
